import { defineStore } from "pinia"
import axios from 'axios'
import { handleError } from '@/plugins/err-handle'

export const useTermodelStore = defineStore("termodel", {
  state: () => ({
    termodels: [],
    currentTermodel: {
      id: null,
      model: '',
      status: null,
      create_at: null
    }
  }),
  getters: {
    // doubleCount: (state) => state.counter + 2,
  },
  actions: {
    // 列表
    fetchItems(data) {
      return new Promise((resolve, reject) => {
        // 表单数据
        axios.get('/admin/termodel', data)
          .then((response) => {
            // console.log('terminal model 2', response) 
            this.termodels = response.data
            resolve(response)
          })
          .catch((err) => {
            handleError(err)
            reject(err)
          })
        })
    },

  },
})